package net.huashitong.oversee.web;

import com.alibaba.druid.sql.visitor.functions.If;
import com.sirdc.modules.core.filter.Paging;
import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.JqGrid;
import com.sirdc.modules.core.web.model.Message;

import com.sirdc.modules.utils.ObjectUtils;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.Project.entity.EarlyWarningNode;
import net.huashitong.Project.entity.MessageList;
import net.huashitong.Project.entity.NewProjects;
import net.huashitong.Project.filter.MessageListFilter;
import net.huashitong.Project.filter.NewProjectsFilter;
import net.huashitong.Project.service.EarlyWarningNodeService;
import net.huashitong.Project.service.MessageListService;
import net.huashitong.Project.service.NewProjectsService;
import net.huashitong.node.entity.NodeNewschedules;
import net.huashitong.node.filter.NodeNewschedulesFilter;
import net.huashitong.node.service.NodeNewschedulesService;
import net.huashitong.oversee.databean.GraphBean;
import net.huashitong.oversee.databean.SupervisionTaskDataBean;
import net.huashitong.oversee.entity.*;
import net.huashitong.oversee.filter.CoordinateFilter;
import net.huashitong.oversee.filter.SupervisionTaskFilter;
import net.huashitong.oversee.filter.TaskLogFilter;
import net.huashitong.oversee.filter.TaskRecordFilter;
import net.huashitong.oversee.service.*;
import net.huashitong.taskGroup.entity.DeptList;
import net.huashitong.taskGroup.entity.JobGroup;
import net.huashitong.taskGroup.service.DeptListService;
import net.huashitong.taskGroup.service.JobGroupService;
import net.huashitong.user.databean.BnpUserDatabean;
import net.huashitong.user.entity.BnpUser;
import net.huashitong.utils.UtilsTools;
import net.huashitong.utils.WordUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.WebUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.*;

/**
 * 督查任务 业务层
 */

@Controller
@RequestMapping("/missions")
public class SupervisionTaskCtrl extends JsonBaseController {

    @Autowired
    private SupervisionTaskService taskService;
    @Autowired
    private SupervisionTaskService supervisionTaskService;
    @Autowired
    private TaskVersionLogService versionLogService;
    @Autowired
    private SupervisionLogService supervisionLogService;
    @Autowired
    private TaskMethonService menthonService;
    @Autowired
    private TaskRecordService taskRecordService;
    @Autowired
    private GradePointService gradePointService;
    @Autowired
    private FeedBackLeaderService feedbackServcie;
    @Autowired
    private NewProjectsService newProjectsService;
    @Autowired
    private NodeNewschedulesService nodeNewschedulesService;
    @Autowired
    private JobGroupService jobGroupService;
    @Autowired
    private DeptListService deptListService;
    @Autowired
    private CoordinateService coordinateService;
    @Autowired
    private MessageListService messageListService;
    @Autowired
    private ScoreSummaryService scoreSummaryService;
    @Autowired
    private EarlyWarningNodeService earlyWarningNodeService;

    @Override
    protected String getView(String s) {
        return "/modules/oversee/" + s;
    }

    /**
     * 初始化页面
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public String initPage(HttpServletRequest request, Model model) {
        String taskId =  request.getParameter("taskId");
        model.addAttribute("leftType", "督查任务");
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (ObjectUtils.isBlank(bnpUser)) {
            return "/modules/login/login";
        }
        model.addAttribute("user", bnpUser);
        //我的督查
        SupervisionTaskFilter taskFilter = new SupervisionTaskFilter();
        taskFilter.setUserinfo(bnpUser.getPhone());
        taskFilter.setBranchType(bnpUser.getBranchType());
        taskFilter.setRole(bnpUser.getRole());
        taskFilter.setValid("1");
        int myTaskNum = supervisionTaskService.getMissinTaskCount(taskFilter);
        WebUtils.setSessionAttribute(request, "myTaskNum", myTaskNum);
        model.addAttribute("myTaskNum", myTaskNum);
        //待办任务个数
        int nodeCount = (int) WebUtils.getSessionAttribute(request, "nodeCount");
        model.addAttribute("nodeCount", nodeCount);

        int quetionNum = (int) WebUtils.getSessionAttribute(request, "quetionNum");
        model.addAttribute("quetionNum", quetionNum);
        if(StringUtils.isNotBlank(taskId)){
            SupervisionTask task = taskService.getById(taskId);
            model.addAttribute("taskCol", taskId);
            model.addAttribute("taskName", task.getTaskName());
        }else{
            model.addAttribute("taskCol", "");
            model.addAttribute("taskName", "");
        }
        return getView("query");
    }

    /**
     * 任务清单查询
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST)
    public JqGrid query(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request, Model model) {
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        //查询督查动态消息列表
        if ("1".equals(filter.getMessageFlag())) {
            MessageListFilter mf = new MessageListFilter();
            mf.setPaging(filter.getPaging());
            if ("4".equals(bnpUser.getBranchType())) {
                //如果是督查组则取督查组编码
                mf.setUserId(bnpUser.getGroupCode());
                mf.setIsRead("0");
            }
            if ("0".equals(bnpUser.getBranchType()) || "1".equals(bnpUser.getBranchType())) {
                mf.setUserId(bnpUser.getSysId());
                mf.setIsRead("0");
            }
            //攻坚管理账号
            if ("2".equals(bnpUser.getBranchType())) {
                mf.setIsRead("0");
            }
            List<MessageList> list = messageListService.queryByFilter(mf);
            List<SupervisionTask> resList = new ArrayList<>();
            for (MessageList m : list) {
                SupervisionTask task = taskService.getById(m.getTaskId());
                if(ObjectUtils.isNotBlank(task)){
                    resList.add(task);
                }
            }
            /**
             * 督查任务菜单列表增加4个字段，放在“督察轮次”后。
             * 1.督查组督查次数 2.责任单位反馈次数 3.督查组最后一次操作时间 4. 责任单位最后一次操作时间
             */
            List<SupervisionTaskDataBean> sdbList = new ArrayList<>();
            for (SupervisionTask task : resList) {
                //督查单位的<催办记录>
                List<SupervisionLog> logs = supervisionLogService.getMissionLog(task.getSysId());
                int supNum = logs.size();
                //被督查单位的<反馈记录>
                List<TaskRecord> records = taskRecordService.getRecordsById(task.getSysId());
                int resNum = records.size();
                SupervisionTaskDataBean sdb = new SupervisionTaskDataBean();
                BeanUtils.copyProperties(task, sdb);
                sdb.setSupervisionNum(supNum + "次");
                sdb.setResDeptNum(resNum + "次");
                if (supNum > 0) {
                    sdb.setSupervisionLastTime(logs.get(0).getCreateDate());
                } else {
                    sdb.setSupervisionLastTime("无");
                }
                if (resNum > 0) {
                    sdb.setResDeptLastTime(records.get(0).getCreateDate());
                } else {
                    sdb.setResDeptLastTime("无");
                }
                sdbList.add(sdb);
            }
            return coverJqGrid(filter, sdbList);
        }
        filter.setUserinfo(bnpUser.getPhone());
        filter.setBranchType(bnpUser.getBranchType());
        filter.setRole(bnpUser.getRole());
        if (StringUtils.isBlank(filter.getGroupId())) {
            filter.setGroupId(bnpUser.getGroupCode());
        }
        List<SupervisionTask> resList = taskService.getTaskLists(filter);

        /**
         * 督查任务菜单列表增加4个字段，放在“督察轮次”后。
         * 1.督查组督查次数 2.责任单位反馈次数 3.督查组最后一次操作时间 4. 责任单位最后一次操作时间
         */
        List<SupervisionTaskDataBean> sdbList = new ArrayList<>();
        for (SupervisionTask task : resList) {
            //督查单位的<催办记录>
            List<SupervisionLog> logs = supervisionLogService.getMissionLog(task.getSysId());
            int supNum = logs.size();
            //被督查单位的<反馈记录>
            List<TaskRecord> records = taskRecordService.getRecordsById(task.getSysId());
            int resNum = records.size();
            SupervisionTaskDataBean sdb = new SupervisionTaskDataBean();
            BeanUtils.copyProperties(task, sdb);
            sdb.setSupervisionNum(supNum + "次");
            sdb.setResDeptNum(resNum + "次");
            if (supNum > 0) {
                sdb.setSupervisionLastTime(logs.get(0).getCreateDate());
            } else {
                sdb.setSupervisionLastTime("无");
            }
            if (resNum > 0) {
                sdb.setResDeptLastTime(records.get(0).getCreateDate());
            } else {
                sdb.setResDeptLastTime("无");
            }
            sdbList.add(sdb);
        }
        return coverJqGrid(filter, sdbList);
    }


    @RequestMapping("/filter")
    public String filter(@ModelAttribute SupervisionTaskFilter filter) {
        return getView("filter");
    }

    //手动新建任务提交
    @ResponseBody
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Message create(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request) {
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        String sysid = supervisionTaskService.saveSupervisionTask(filter, bnpUser.getName());
        if (StringUtils.isBlank(sysid)) {
            return coverMessage("500", "任务创建失败，请联系管理员");
        }
        //保存到督查系统
//        supervisionTaskService.saveTasktoDuCha(sysid);
        return coverMessage("200");
    }

    /**
     * 手动新建任务
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String showAddView(@ModelAttribute SupervisionTaskFilter filter, Model model) {
        //SupervisionTask task  = supervisionTaskService.getById(id);
        //查询未完成项目
        NewProjectsFilter f = new NewProjectsFilter();
        f.setStatus("3");
        List<NewProjects> newProjectsList = newProjectsService.queryByfilter(f);
        List<JobGroup> jobGroups = jobGroupService.query();
        //涉及单位（involveUnit）
        List<BnpUserDatabean> deptLists = coordinateService.queryAllInvolveUnit();
        model.addAttribute("newProjectsList", newProjectsList);
        model.addAttribute("jobGroups", jobGroups);
        model.addAttribute("deptLists", deptLists);
        model.addAttribute("taskjob", filter);
        return getView("creatTask");
    }

    /**
     * 添加完成情况（责任单位）
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/createRespRecord/{id}", method = RequestMethod.GET)
    public String showRespEdit(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("task", task);
        List<TaskRecord> lists = taskRecordService.getRecordsById(id);
        model.addAttribute("listRecords", lists);
        List<SupervisionLog> logs = supervisionLogService.getMissionLog(id);
        for (SupervisionLog items : logs) {
            //填写时间格式去掉-
            items.setCreateDate(items.getCreateDate().replace("-", ""));
            TaskMethon method = menthonService.getMethon(items.getMethonCode());
            if (ObjectUtils.isNotBlank(method)) {
                items.setMethonName(method.getMethonName());
            }
        }
        model.addAttribute("supervisionLogs", logs);
        return getView("addCompletion_form");
    }

    /**
     * 完成情况提交（责任单位）
     **/
    @ResponseBody
    @RequestMapping(value = "/createRespRecord", method = RequestMethod.POST)
    public Message createCompleteInfo(@ModelAttribute TaskRecordFilter filter) throws ParseException {

//        if (StringUtils.isBlank(filter.getTaxproof())) {
//            //没有上传佐证材料
//            return coverMessage("201", "提交失败，没有上传佐证材料", false);
//        }
        filter.setTaskId(filter.getSysId());
        filter.setSysId(null);
        SupervisionTask task = supervisionTaskService.getById(filter.getTaskId());
        filter.setResDept(task.getResDept());
        filter.setSupervisionTeamId(task.getGroupId());
        boolean flag = taskRecordService.saveRocord(filter); //保存完成情况
        if (!flag) {
            //无添加记录
            return coverMessage("201", "记录填写不规范", false);
        }
        //添加督查动态消息列表
        MessageList messageList = new MessageList();
        messageList.setIsRead("0");
        messageList.setTaskId(task.getSysId());
        messageList.setUserId(task.getGroupId());
        messageListService.save(messageList);

        return coverMessage("200");
    }


    /**
     * 修改查看任务详情
     *
     * @param
     * @return
     */

    @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
    public String showEdit(Model model, HttpServletRequest request, @PathVariable String id) {

        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");

        SupervisionTask task = supervisionTaskService.getById(id);

        //如果用户是督查组，并且督查任务有未读情况，则需要提示
        if ("4".equals(bnpUser.getBranchType())) {
            MessageListFilter mf = new MessageListFilter();
            mf.setUserId(bnpUser.getGroupCode());
            mf.setTaskId(id);
            mf.setIsRead("0");
            List<MessageList> list = messageListService.queryNoReadMessage(mf);
            if (ObjectUtils.isNotBlank(list)) {
                //责任单位反馈的消息督查组未读
                model.addAttribute("resNoRead", "1");
            }
        } else {
            MessageListFilter mf = new MessageListFilter();
            mf.setUserId(bnpUser.getSysId());
            mf.setTaskId(id);
            mf.setIsRead("0");
            List<MessageList> list = messageListService.queryNoReadMessage(mf);
            if (ObjectUtils.isNotBlank(list)) {
                model.addAttribute("superNoRead", "1");
            }
        }


        List<JobGroup> jobGroups = jobGroupService.query();
        /**
         * 已经选择的督查组
         */
        if (StringUtils.isNotBlank(task.getGroupType())) {
            String[] grpups = task.getGroupType().toString().split(",");
            List<String> groupsList = Arrays.asList(grpups);
            for (String item2 : groupsList) {
                for (JobGroup item : jobGroups) {
                    if (item.getGroupName().equals(item2)) {
                        item.setGroupDuty("selected");
                    } else {
                        item.setGroupDuty("noSelected");
                    }
                }
            }
        }


        //涉及单位（involveUnit）
        List<BnpUserDatabean> deptLists = coordinateService.queryAllInvolveUnit();
        String involveUnitsStr = task.getInvolveUnit();
        if (StringUtils.isNotBlank(involveUnitsStr)) {
            String[] invArr = involveUnitsStr.split(",");
            List<String> involveUnitsList = Arrays.asList(invArr);
            for (BnpUserDatabean dept : deptLists) {
                boolean flag = false;
                for (String involve : involveUnitsList) {
                    if (involve.equals(dept.getBranch())) {
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    dept.setBranchType("selected");
                } else {
                    dept.setBranchType("noSelected");
                }
            }
        } else {
            for (BnpUserDatabean dept : deptLists) {
                dept.setBranchType("noSelected");
            }
        }
        List<SupervisionTask> list = new ArrayList<>();
        list.add(task);
        list = supervisionTaskService.involveUnitDealWith(list);
        model.addAttribute("jobGroups", jobGroups);
        model.addAttribute("taskjob", list.get(0));
        model.addAttribute("bnpUser", bnpUser);
        model.addAttribute("deptLists", deptLists);
        return getView("form");
    }

    /**
     * 修改任务
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public Message editTaskJob(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request) {

        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        //如果该用户是督查组角色，则不能修改督查组别
        if ("4".equals(bnpUser.getBranchType())) {
            filter.setGroupId(task.getGroupId());
        }

        // String oldStage = task.getTaskStage();
        if (ObjectUtils.isBlank(task)) {
            return coverMessage("500", "找不到该任务，请刷新页面");
        }
        if ("0".equals(task.getAaa001())) {
            return coverMessage("500", "改任务已经失效，不可修改");
        }
        filter.setTasktimes(task.getTasktimes());
        filter.setProjectId(task.getProjectId());
        filter.setOverdueDays(task.getOverdueDays());
        filter.setNodeSysId(task.getNodeSysId());
        filter.setSupervisionResult(task.getSupervisionResult());
        filter.setRespResult(task.getRespResult());
        filter.setTaskResult(task.getTaskResult());
        supervisionTaskService.updateTaskJob(filter, task);
        return coverMessage("200", "任务创建成功");
    }

    /**
     * 重新生成任务
     *
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value = "/rebuildjob/{id}", method = RequestMethod.GET)
    public String showreJob(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("taskjob", task);
        return getView("restartForm");
    }

    /**
     * 重新生成任务节点。
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/rebuildjob", method = RequestMethod.POST)
    public Message rebuildJob(@ModelAttribute SupervisionTaskFilter filter) {

        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        if (ObjectUtils.isBlank(task)) {
            return coverMessage("500", "找不到该任务，请刷新页面");
        }
        /**
         * 旧的任务存档
         */
        TaskVersionLog versionlog = new TaskVersionLog();
        BeanUtils.copyProperties(task, versionlog);
        versionLogService.save(versionlog);

        //记录旧的记录
        task.setRespResult("0"); //责任单位结果改为0
        task.setSupervisionResult("0"); //督查组单位改为未完成  0
        task.setTaskResult("0"); //最终结果改为 0
        String times = StringUtils.isBlank(task.getTasktimes()) ? "1" : task.getTasktimes();

        Integer tasktimes = Integer.parseInt(times);
        if (tasktimes == 3) {
            return coverMessage("500", "督查任务最多生成3轮，该任务已经生成3轮");
        }
        tasktimes = tasktimes + 1;
        task.setTasktimes(tasktimes.toString());
        supervisionTaskService.update(task);
        // supervisionTaskService.updateTaskJob(filter,task);
        return coverMessage("200", "重新生成任务成功");
    }

    /*@ResponseBody
    @RequestMapping(value = "/creatTask", method = RequestMethod.POST)
    public Message creatSupervisionTask(@RequestBody SupervisionTaskFilter filter) {
        String projectId = filter.getProjectId();       //项目id      不能为空
        String nodeId = filter.getNodeId();             //节点号       不能为空
        String taskName = filter.getTaskName();         //任务名称      不能为空
        NodeNewschedules nodeNewschedules = nodeNewschedulesDao.getNodeNewschedulesByProjectIdAndNodeId(projectId, nodeId);
        NewProjects np = newProjectsService.getById(projectId);
        SupervisionTask task = new SupervisionTask();
        task.setTaskName(taskName);
        task.setTaskContent(filter.getTaskContent());
        task.setProjectId(projectId);
        task.setNodeId(nodeId);
        task.setProjectName(np.getName());                              //项目名称
        task.setNodeName(nodeNewschedules.getNodeName());               //节点名称
        task.setResUser(nodeNewschedules.getResUser());                 //责任人
        task.setResPhone(nodeNewschedules.getResUserPhone());           //责任人手机号
        task.setResDept(nodeNewschedules.getResDept());                 //责任单位
        task.setOperatorUser(nodeNewschedules.getOperatorUser());       //经办人
        task.setOperatorPhone(nodeNewschedules.getOperatorPhone());     //经办人手机号
        task.setInspectors(filter.getInspectors());
        task.setGroupType(filter.getGroupType());
        task.setStartDate(getNowDate());                                //设置开始时间（创建项目的时间）
        supervisionTaskService.save(task);
        return coverMessage("200", "任务创建成功");
    }*/

    /**
     * 添加催办记录。（督查组）
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/createTaskLog", method = RequestMethod.POST)
    public Message creatTaskLog(@ModelAttribute TaskLogFilter filter) throws ParseException {
        filter.setTaskId(filter.getSysId());
        filter.setSysId(null);
        SupervisionTask task = supervisionTaskService.getById(filter.getTaskId());
        filter.setTasktimes(task.getTasktimes());
        boolean isRight = supervisionLogService.saveCuiBanLog(filter);
        if (!isRight) {
            //无添加记录
            return coverMessage("201", "记录填写不规范", false);
        }
        //添加督查动态消息列表
        MessageList messageList = new MessageList();
        messageList.setIsRead("0");
        messageList.setTaskId(task.getSysId());
        messageList.setUserId(task.getUserid());
        messageListService.save(messageList);

        return coverMessage("200", "提交成功", true);
    }

    /**
     * 打开催办记录按钮（我要催办）
     *
     * @param id
     * @param model
     * @return
     */
    @RequestMapping(value = "/createTaskLog/{id}", method = RequestMethod.GET)
    public String showTaskLogView(@PathVariable String id, HttpServletRequest request, Model model) {
        //督查任务
        SupervisionTask task = supervisionTaskService.getById(id);
        //判断用户是否跟督查任务有关联
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        List<TaskMethon> methods = menthonService.getAllMethon();
        model.addAttribute("task", task);
        model.addAttribute("nodeSysId", task.getNodeSysId());
        model.addAttribute("methods", methods);
        List<SupervisionLog> supervisionLogs = supervisionLogService.getMissionLog(id);
        for (SupervisionLog items : supervisionLogs) {
            TaskMethon methon = menthonService.getMethon(items.getMethonCode());
            if (ObjectUtils.isNotBlank(methon)) {
                items.setMethonName(methon.getMethonName());
            }

        }
        //填写时间格式去掉-
        for (SupervisionLog s : supervisionLogs) {
            s.setCreateDate(s.getCreateDate().replace("-", ""));
        }
        model.addAttribute("supervisionLogs", supervisionLogs);
        List<TaskRecord> lists = taskRecordService.getRecordsById(id);
        model.addAttribute("listRecords", lists);
        //督查成员
        String[] inspectors = task.getInspectors().split(",");
        boolean flag = false;
        for (String i : inspectors) {
            if (bnpUser.getName().equals(i)) {
                flag = true;
            }
        }
        //超级管理员有权限添加催办记录
        if ("2".equals(bnpUser.getBranchType())) {
            return getView("logForm");
        } else if (flag) {
            return getView("logForm");
        } else {
            return null;
        }
    }


    /**
     * 修改查看任务详情
     *
     * @param
     * @return
     */

    @RequestMapping(value = "/feedback/{id}", method = RequestMethod.GET)
    public String showfeedback(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        /*SupervisionTask task  = new SupervisionTask();*/
        String msg = "【重大项目节点管理】您好!督查任务:" + task.getTaskName() + ",任务结果:未完成,该督查组" + "无" + "督查催办记录.督查小组为:" + task.getGroupType() + ",责任单位为:" + task.getResDept() + ",请及时处理。系统地址：https://www.fzzhengxinyun.com ，帐号为个人手机号，初始密码123456";
        model.addAttribute("taskjob", task);
        model.addAttribute("msgToLeader", msg);
        return getView("feedbackform");
    }

    /**
     * 任务清单查询
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/feedback", method = RequestMethod.POST)
    public Message feedbackEdit(@ModelAttribute SupervisionTaskFilter filter) {
        //List<DutyUnit> lists =  service.getUnitInfo(filter);
        System.out.println("发短信通知领导了");
        /*return coverJqGrid(filter,lists);*/
        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        if (ObjectUtils.isNotBlank(task))
            feedbackServcie.feedLeader(task, filter.getTelphone());
        return coverMessage("200", "发送成功");
    }


    /**
     * 添加问题（提请协调）
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/addProblem/{id}", method = RequestMethod.GET)
    public String showAddProblem(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        String projectDetail = task.getTaskName() + ",目前已经逾期" +
                task.getOverdueDays() + "天,正处于第" + task.getTasktimes() + "轮督查任务。";
        model.addAttribute("task", task);
        model.addAttribute("projectDetail", projectDetail);
        return getView("addProblemForm");
    }

    /**
     * 生成问题
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/addProblem", method = RequestMethod.POST)
    public Message addProblem(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request, Model model) {
        if (StringUtils.isBlank(filter.getFeedback())) {
            return coverMessage("201", "提交失败，问题描述不能为空！");
        }
        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());

        //验证是否已有相关问题，有的话则不必再次生产问题
        CoordinateFilter cf = new CoordinateFilter();
        cf.setNodeSysId(task.getNodeSysId());
        List<Coordinate> cList = coordinateService.queryCoordinates(cf);
        if (ObjectUtils.isNotBlank(cList) && cList.size() > 0) {
            return coverMessage("201", "该问题已提交申请攻坚，不必重复提交！");
        }

        Coordinate problem = new Coordinate();
        //获取县分管领导
        if (StringUtils.isNotBlank(task.getProjectId())) {
            NewProjects projects = newProjectsService.getById(task.getProjectId());
            if (ObjectUtils.isNotBlank(projects)) {
                problem.setfGcountyLeader(projects.getResUser());
                problem.setfGcountyLeaderPhone(projects.getResPhone());
                problem.setOrganizer(projects.getResDept());            //承办单位
            }
        }
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        problem.setAaa001("1");                             //有效标志
        problem.setProjectName(task.getProjectName());      //项目名称
        problem.setHelpInfo(filter.getFeedback());          //需协调事项
        problem.setBaseInfo(task.getTaskContent());         //基本情况
        problem.setResDept(task.getResDept());              //责任单位
        problem.setOperator(task.getOperatorUser());        //经办人
        problem.setOperatorPhone(task.getOperatorPhone());  //经办人手机号
        problem.setResUser(task.getResUser());              //责任人
        problem.setResUserPhone(task.getResPhone());        //责任人手机号
        problem.setInvolveUnit(task.getGroupType());        //督查组
        problem.setReportUser(bnpUser.getName());           //上报人
        problem.setReportUserPhone(bnpUser.getPhone());     //上报人手机号
        problem.setUserId(bnpUser.getSysId());              //上报人Id
        problem.setReportTime(UtilsTools.getCurrentDate()); //上报时间
        problem.setContact(task.getOperatorUser());         //联系人
        problem.setTaxproof(filter.getTaxproof());          //攻坚文件上传
        problem.setNodeSysId(task.getNodeSysId());          //节点sysId
        problem.setTaskId(task.getSysId());                 //督查任务Id
        coordinateService.save(problem);
        //我的协调
        CoordinateFilter coordinateFilter = new CoordinateFilter();
        coordinateFilter.setUserinfo(bnpUser.getPhone());
        coordinateFilter.setBranchType(bnpUser.getBranchType()); //设置查询权限
        if (StringUtils.isBlank(coordinateFilter.getGroupCode())) //督查组权限
        {
            coordinateFilter.setGroupCode(bnpUser.getGroupCode());
        }
        int quetionNum = coordinateService.queryCoordinateCount(coordinateFilter);
        model.addAttribute("quetionNum", quetionNum);
        WebUtils.setSessionAttribute(request, "quetionNum", quetionNum);
        return coverMessage("200", "提交成功");
    }


    /**
     * 节点图流程
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping("/getTaskNodes")
    public Message getTaskNodes(@RequestBody SupervisionTaskFilter filter) {
        logger.info("流程开始时间 -----" + UtilsTools.getCurrentDateTime() + "---------------");
        //流程图阶段拼接
        String[] allNodes = {"任务生成", "任务开始", "任务执行中", "任务完成", "任务未完成", "反馈攻坚", "完成情况", "督查记录", "督查组需协调事项", "责任单位需协调事项", "督查得分"};
        List<GraphBean> lists = new ArrayList<>();
        GraphBean bean = new GraphBean();
        bean.setSource("任务生成");
        bean.setTarget("任务开始");
        lists.add(bean);
        bean = new GraphBean();
        bean.setSource("任务开始");
        bean.setTarget("任务执行中");
        lists.add(bean);
        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        //判断是否有督查记录
        List<SupervisionLog> logs = supervisionLogService.getMissionLog(task.getSysId());
        if (ObjectUtils.isNotBlank(logs)) {
            bean = new GraphBean();
            bean.setSource("任务执行中");
            bean.setTarget("督查记录");
            lists.add(bean);
        }
        //是否有完成情况
        List<TaskRecord> records = taskRecordService.getRecordsById(task.getSysId());
        if (ObjectUtils.isNotBlank(records)) {
            bean = new GraphBean();
            bean.setSource("任务执行中");
            bean.setTarget("完成情况");
            lists.add(bean);
        }
        if ("1".equals(task.getTaskResult())) //任务是否完成 1 完成
        {
            bean = new GraphBean();
            bean.setSource("任务执行中");
            bean.setTarget("任务完成");
            lists.add(bean);
            bean = new GraphBean();
            bean.setSource("任务完成");
            bean.setTarget("督查得分");
            lists.add(bean);
        } else {  // 未完成
            Date planEnd = null;
            Date enddate = null;
            try {
                planEnd = UtilsTools.StringToDate(task.getPlanEndDate());
                enddate = UtilsTools.StringToDate(UtilsTools.getCurrentDate());
                if (planEnd.compareTo(enddate) < 0)   //15天后 是否完成
                {
                    bean = new GraphBean();
                    bean.setSource("任务执行中");
                    bean.setTarget("任务未完成");
                    lists.add(bean);
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if ("1".equals(task.getIsfeedback())) //未完成是否反馈给攻坚办
            {
                bean = new GraphBean();
                bean.setSource("任务未完成");
                bean.setTarget("反馈攻坚");
                lists.add(bean);
                if ("1".equals(task.getTaskResult()))//再次判断任务是否完成
                {
                    bean = new GraphBean();
                    bean.setSource("反馈攻坚");
                    bean.setTarget("督查得分");
                    lists.add(bean);
                  /*  bean  = new GraphBean();
                    bean.setSource("任务完成");
                    bean.setTarget("督查得分");
                    lists.add(bean);*/
                } else {
                    //判断是否再次生成任务
                    bean = new GraphBean();
                    bean.setSource("反馈攻坚");
                    bean.setTarget("任务生成");
                    lists.add(bean);
                }
            }
          /*  bean  = new GraphBean();
            bean.setSource("任务完成");
            bean.setTarget("督查得分");
            lists.add(bean);*/
        }
        Map<String, Object> map = new HashMap<>();
        map.put("graph", lists);
        int[] greenNode = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
        for (GraphBean item : lists) {
            for (int i = 0; i < allNodes.length; i++) {
                if (item.getTarget().equals(allNodes[i])) {
                    greenNode[i] = 0;
                }
            }
        }
        map.put("green", greenNode);
        logger.info("结束时间 -----" + UtilsTools.getCurrentDateTime() + "---------------");
        return coverMessage("200", "successful", map);
    }


    @ResponseBody
    @RequestMapping(value = "/queryNodeIdByProjectName", method = RequestMethod.POST)
    public Message queryNodeIdByProjectName(@RequestBody NewProjectsFilter params) {
        if (StringUtils.isNotBlank(params.getName())) {
            NewProjectsFilter filter = new NewProjectsFilter();
            filter.setName(params.getName());
            List<NewProjects> list = newProjectsService.getProjectInfoPage(filter);
            List<String> smallNodes = new ArrayList<>();
            if (ObjectUtils.isNotBlank(list)) {
                NewProjects newProjects = list.get(0);
                String projectId = newProjects.getSysId();
                //查询所有未结束的节点并且已经确定的节点
                List<NodeNewschedules> nodeNewschedules = nodeNewschedulesService.getNoFinishNode(projectId);
                for (NodeNewschedules node : nodeNewschedules) {
                    if ("1".equals(node.getState()) && !("业主单位".equals(node.getResDept())
                            || "业主、中介机构".equals(node.getResDept())
                            || "中介机构".equals(node.getResDept())
                    )) {
                        smallNodes.add(node.getNodeId());
                    }
                }
            }
            return coverMessage("200", "获取节点ID成功", smallNodes);
        }
        return coverMessage("200", "成功");
    }

    @ResponseBody
    @RequestMapping(value = "/queryNodeNameByNodeIdAndProjectID", method = RequestMethod.POST)
    public Message queryNodeNameByNodeIdAndProjectID(@RequestBody NodeNewschedulesFilter params) {
        String projectId = params.getProjectId();
        String nodeId = params.getNodeId();
        NodeNewschedules nodeNewschedules = nodeNewschedulesService.getNnsByProjectIdAndNodeId(projectId, nodeId);
        return coverMessage("200", "成功", nodeNewschedules);
    }


    /**
     * 删除扯回任务 deletejob
     */

    @RequestMapping(value = "/deletejob/{id}", method = RequestMethod.GET)
    public String showDeleteJob(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("taskjob", task);
        // model.addAttribute("msgToLeader",msg);
        return getView("remarkForm");
    }

    /**
     * 任务清单查询
     *
     * @param filter
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/deletejob", method = RequestMethod.POST)
    public Message deleteJob(@ModelAttribute SupervisionTaskFilter filter) {

        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        List<String> delList = new ArrayList<>();
        if (ObjectUtils.isNotBlank(task)) {
            String nodeSysId = task.getNodeSysId();
            EarlyWarningNode warningNode = earlyWarningNodeService.queryEarlyWarningNodeByNodeSysId(nodeSysId);
            if(ObjectUtils.isNotBlank(warningNode)){
                warningNode.setState("1");
                earlyWarningNodeService.update(warningNode);
            }
            task.setAaa001("0");
            task.setAaa002("1");
            task.setRemarks(filter.getRemarks());
            delList.add(task.getSysId());
            task.setRespScore("0.0");
            task.setSupervisionScore("0.0");
            supervisionTaskService.update(task);
            //删除相应的绩效得分
            gradePointService.deletAllInvalidTaskGradePoint(delList);
            //更新绩效得分情况
            gradePointService.updateRank();
            scoreSummaryService.updateSummaryScore();
            scoreSummaryService.updateSummaryScoreRank();
            String updateScore = supervisionTaskService.updateAllTaskRespAndSupervisionScore();
            if ("ok".equals(updateScore)) {
                System.out.println("*****************更新督查任务得分完成*****************");
            }
            scoreSummaryService.updateSummaryScoreTypeRank();
        } else {
            return coverMessage("500", "操作失败，找不到该任务");
        }
        return coverMessage("200", "操作成功");
    }

    /**
     * 督查详情
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/supervisionAskList/{id}", method = RequestMethod.GET)
    public String showSupervisionAskList(Model model, HttpServletRequest request, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("task", task);
        List<SupervisionLog> logs = supervisionLogService.getMissionLog(id);
        for (SupervisionLog items : logs) {
            TaskMethon methon = menthonService.getMethon(items.getMethonCode());
            if (ObjectUtils.isNotBlank(methon)) {
                items.setMethonName(methon.getMethonName());
            }
            if (StringUtils.isBlank(items.getDatatime())) {
                items.setDatatime(items.getCreateTime().replace("-", ""));
            }
        }
        model.addAttribute("logs", logs);
        //业主单位或者审批部门查看督查详情，则督查动态改成已读
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if (("0".equals(bnpUser.getBranchType()) || "1".equals(bnpUser.getBranchType()))
                && StringUtils.isNotBlank(bnpUser.getSysId())) {
            MessageListFilter mf = new MessageListFilter();
            mf.setIsRead("0");
            mf.setUserId(bnpUser.getSysId());
            mf.setTaskId(task.getSysId());
            List<MessageList> list = messageListService.queryNoReadMessage(mf);
            for (MessageList messageList : list) {
                messageList.setIsRead("1");
            }
            messageListService.batchUpdate(list);
        }

        return getView("supervisionAskList");
    }

    /**
     * 反馈详情
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/feedbackInfoList/{id}", method = RequestMethod.GET)
    public String showfeedbackInfoList(Model model, HttpServletRequest request, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("datebean", task);
        //被督查单位的<反馈记录>
        List<TaskRecord> lists = taskRecordService.getRecordsById(id);
        for (TaskRecord record : lists) {
            if (StringUtils.isBlank(record.getDatatime())) {
                record.setDatatime(record.getCreateTime().replace("-", ""));
            }
        }
        model.addAttribute("listRecords", lists);
        //督查组查看反馈记录，则督查动态更改未读状态
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        if ("4".equals(bnpUser.getBranchType()) && StringUtils.isNotBlank(bnpUser.getGroupCode())) {
            MessageListFilter mf = new MessageListFilter();
            mf.setIsRead("0");
            mf.setUserId(bnpUser.getGroupCode());
            mf.setTaskId(task.getSysId());
            List<MessageList> list = messageListService.queryNoReadMessage(mf);
            for (MessageList messageList : list) {
                messageList.setIsRead("1");
            }
            messageListService.batchUpdate(list);
        }

        return getView("feedbackInfoList");
    }

    /**
     * 添加办结情况（督查组）
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/confirmationSup/{id}", method = RequestMethod.GET)
    public String confirmationSup(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("task", task);

        NodeNewschedules node = nodeNewschedulesService.getNnsByProjectIdAndNodeId(task.getProjectId(), task.getNodeId());
        String nodeFile = node.getNodeFilter();
        model.addAttribute("nodeFile", nodeFile);

        NodeNewschedules nodeNewschedules = nodeNewschedulesService.getById(task.getNodeSysId());
        if (ObjectUtils.isNotBlank(nodeNewschedules)) {
            //已完成
            if ("2".equals(nodeNewschedules.getStatus())) {
                model.addAttribute("nodeStatus", "1");
            } else {
                model.addAttribute("nodeStatus", "0");
            }
        } else {
            model.addAttribute("nodeStatus", "2");
        }
        return getView("confirmationSup");
    }

    /**
     * 添加办结情况（督查组）
     *
     * @param
     * @return url
     */
    @ResponseBody
    @RequestMapping(value = "/confirmationSup", method = RequestMethod.POST)
    public Message updateConfirmationSup(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request) throws ParseException {
        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
        task.setSupervisionResult(filter.getSupervisionResult());
        NodeNewschedules nodeNewschedules = nodeNewschedulesService.getById(task.getNodeSysId());
        //任务节点的状态status（0未完成，1进行中，2已完成）
        String status = StringUtils.isBlank(nodeNewschedules.getStatus()) ? "0" : nodeNewschedules.getStatus();
        if ("1".equals(task.getSupervisionResult()) && "1".equals(task.getRespResult()) && "2".equals(status)) {
            //判断是否超时完成督查任务
            Date EndDate = UtilsTools.StringToDate(task.getPlanEndDate());//计划结束时间，
            Date currentDate = UtilsTools.StringToDate(UtilsTools.getCurrentDate());//当前日期
            int flag = EndDate.compareTo(currentDate); //计划结束时间和当前时间比较。是否到期。
            if (flag < 0 && "3".equals(task.getTasktimes())) {
                //超时了
                task.setTaskResult("4"); //任务结果已考评（超时完成），不重新计分
            } else {
                task.setTaskResult("1"); //任务最终结果完成1
            }
            task.setAaa002("1");
            task.setEndDate(UtilsTools.getCurrentDate());
            supervisionTaskService.update(task);
            gradePointService.saveGroupSocure(task);
            gradePointService.saveGroupScoreInOperator(task);
            gradePointService.saveGroupScoreInResUer(task);
        } else {
            task.setEndDate(null);
            //任务最终结果未完成0
            task.setTaskResult("0");
            supervisionTaskService.update(task);
        }

        return coverMessage("200", "提交成功", true);
    }


    /**
     * 添加办结情况（责任单位）
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/confirmationRes/{id}", method = RequestMethod.GET)
    public String confirmationRes(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("task", task);
        NodeNewschedules nodeNewschedules = nodeNewschedulesService.getById(task.getNodeSysId());
        if (ObjectUtils.isNotBlank(nodeNewschedules)) {
            //已完成
            if ("2".equals(nodeNewschedules.getStatus())) {
                model.addAttribute("nodeStatus", "1");
            } else {
                model.addAttribute("nodeStatus", "0");
            }
        } else {
            model.addAttribute("nodeStatus", "2");
        }
        return getView("confirmationRes");
    }

    /**
     * 添加办结情况（责任单位）
     *
     * @param
     * @return url
     */
//    @ResponseBody
//    @RequestMapping(value = "/confirmationRes", method = RequestMethod.POST)
//    public Message updateConfirmationRes(@ModelAttribute SupervisionTaskFilter filter, HttpServletRequest request) throws ParseException {
//        SupervisionTask task = supervisionTaskService.getById(filter.getSysId());
//        task.setRespResult(filter.getRespResult());
//        NodeNewschedules nodeNewschedules = nodeNewschedulesService.getById(task.getNodeSysId());
//        //任务节点的状态status（0未完成，1进行中，2已完成）
//        String status = StringUtils.isBlank(nodeNewschedules.getStatus()) ? "0" : nodeNewschedules.getStatus();
//        if ("1".equals(task.getRespResult()) && "2".equals(status)) {
//            task.setTaskResult("0"); //任务最终结果完成1
//            task.setEndDate(UtilsTools.getCurrentDate());
//            supervisionTaskService.update(task);
//            gradePointService.saveGroupScoreInOperator(task);
//            gradePointService.saveGroupScoreInResUer(task);
//        } else {
//            task.setEndDate(null);
//            //任务最终结果未完成0
//            task.setTaskResult("0");
//            supervisionTaskService.update(task);
//        }
//        return coverMessage("200", "提交成功", true);
//    }
    @RequestMapping("/formHead")
    public String showHead(@ModelAttribute NodeNewschedulesFilter filter, Model model) {
        return getView("formHead");
    }

    @RequestMapping(value = "/projectReport/{id}", method = RequestMethod.GET)
    public String showProjectReport(Model model, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        model.addAttribute("task", task);
        return getView("projectReport");
    }

    /**
     * 获取各督查轮数的个数
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getSupervisionNums")
    public Message getSupervisionNums(HttpServletRequest request) {
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        Map<String, Integer> integerMap = supervisionTaskService.getSupervisionNums(bnpUser);
        return coverMessage("200", "查询成功", integerMap);
    }

    /**
     * 查看督查过程日志
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/readLog/{id}", method = RequestMethod.GET)
    public String readLog(Model model, HttpServletRequest request, @PathVariable String id) {
        //督查记录（SupervisionLog）、完成情况（TaskRecord）
        SupervisionTask task = supervisionTaskService.getById(id);
        //督查单位的<催办记录>
        List<SupervisionLog> logs = supervisionLogService.getMissionLog(id);
        //责任单位的<反馈记录>
        List<TaskRecord> records = taskRecordService.getRecordsById(id);

        List<SupervisionLog> newLogs = new ArrayList<>();
        for (TaskRecord log : records) {
            SupervisionLog supervisionLog = new SupervisionLog();
            supervisionLog.setTaxproof(log.getTaxproof());
            supervisionLog.setCreateDate(log.getCreateDate());
            supervisionLog.setCreateTime(log.getCreateTime());
            supervisionLog.setRecord(log.getRecord());
            supervisionLog.setTaskId(log.getTaskId());
            supervisionLog.setDatatime(log.getDatatime());
            supervisionLog.setSupervisionTeamId(log.getSupervisionTeamId());
            newLogs.add(supervisionLog);
        }
        logs.addAll(newLogs);
        Collections.sort(logs, new Comparator<SupervisionLog>() {
            @Override
            public int compare(SupervisionLog h1, SupervisionLog h2) {
                String c1 = h1.getCreateDate() + " " + h1.getCreateTime();
                String c2 = h2.getCreateDate() + " " + h2.getCreateTime();
                return c1.compareTo(c2);
            }
        });
        model.addAttribute("logs", logs);

        List<TaskMethon> methods = menthonService.getAllMethon();
        model.addAttribute("task", task);
        model.addAttribute("nodeSysId", task.getNodeSysId());
        model.addAttribute("methods", methods);
        BnpUser bnpUser = (BnpUser) WebUtils.getSessionAttribute(request, "user");
        model.addAttribute("bnpUser", bnpUser);

        //页面历史记录
        List<SupervisionLog> supervisionLogs = supervisionLogService.getMissionLog(id);
        for (SupervisionLog items : supervisionLogs) {
            TaskMethon methon = menthonService.getMethon(items.getMethonCode());
            if (ObjectUtils.isNotBlank(methon)) {
                items.setMethonName(methon.getMethonName());
            }
        }
        //填写时间格式去掉-
        for (SupervisionLog s : supervisionLogs) {
            s.setCreateDate(s.getCreateDate().replace("-", ""));
        }
        model.addAttribute("supervisionLogs", supervisionLogs);
        List<TaskRecord> lists = taskRecordService.getRecordsById(id);
        model.addAttribute("listRecords", lists);

        //督查过程日志
        return getView("inspectionLog");
    }

    /**
     * @param reponse
     * @param id
     */
    @ResponseBody
    @RequestMapping(value = "/exportProjectReportInWord/{id}", method = RequestMethod.GET)
    public void exportProjectReportInWord(HttpServletResponse reponse, @PathVariable String id) {
        SupervisionTask task = supervisionTaskService.getById(id);
        if (StringUtils.isNotBlank(task.getProjectId())) {
            NewProjects project = newProjectsService.getById(task.getProjectId());
            if (ObjectUtils.isNotBlank(project)) {
                //督查单位的<催办记录>
                List<SupervisionLog> logs = supervisionLogService.getMissionLog(id);
                //被督查单位的<反馈记录>
                List<TaskRecord> records = taskRecordService.getRecordsById(id);

                List<SupervisionLog> newLogs = new ArrayList<>();
                for (TaskRecord log : records) {
                    SupervisionLog supervisionLog = new SupervisionLog();
                    supervisionLog.setTaxproof(log.getTaxproof());
                    supervisionLog.setCreateDate(log.getCreateDate());
                    supervisionLog.setCreateTime(log.getCreateTime());
                    supervisionLog.setRecord(log.getRecord());
                    supervisionLog.setTaskId(log.getTaskId());
                    supervisionLog.setDatatime(log.getDatatime());
                    supervisionLog.setSupervisionTeamId(log.getSupervisionTeamId());
                    newLogs.add(supervisionLog);
                }
                logs.addAll(newLogs);
                Collections.sort(logs, new Comparator<SupervisionLog>() {
                    @Override
                    public int compare(SupervisionLog h1, SupervisionLog h2) {
                        String c1 = h1.getCreateDate() + " " + h1.getCreateTime();
                        String c2 = h2.getCreateDate() + " " + h2.getCreateTime();
                        return c1.compareTo(c2);
                    }
                });
                supervisionTaskService.exportProjectReportWord(reponse, project, task, logs);
            }
        } else {

        }

    }

}
